package com.experience.we.lambda;

import java.util.Arrays;
import java.util.List;

import static java.util.stream.Collectors.toList;

public class StreamFilter {

    public static void main(String[] args) {

        List<Integer> list = Arrays.asList(1,2,3,4,4,6,2,1,4,2,4,5,6,7,8,9);
        //偶数
        List<Integer> result = list.stream().filter(s -> s % 2 == 0).collect(toList());
        System.out.println(result);

        //去重
        List<Integer> collect = list.stream().distinct().collect(toList());
        System.out.println(collect);

        //跳过前五个
        List<Integer> collect1 = list.stream().skip(5).collect(toList());
        System.out.println(collect1);

        //limit
        List<Integer> collect2 = list.stream().limit(50).collect(toList());
        System.out.println(collect2);

    }
}
